<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="shortcut icon" href="../images/favicon.ico">
    <link rel="apple-touch-icon-precomposed" href="../images/apple-touch-icon.png">
    <title>imglazy</title>
    <link rel="stylesheet" href="../scripts/lib/seedsui/seedsui.min.css">
    <style>
    .lazyimg{
        display: block;
        width: 100%;
        min-height: 210px;
        background-color: #ccc;
        margin-bottom:4px;
    }
    </style>
</head>

<body ontouchstart="">
        <header>
            <div class="titlebar">
                <a class="titlebar-button" href="javascript:back()"><i class="icon icon-arrowleft"></i></a>
                <h1 class="titlebar-title">预加载</h1>
                <a class="titlebar-button" id="ID-BtnRefresh">刷新</a>
            </div>
        </header>
        <article>
            <img data-load-src="../images/1.jpg" src="" class="lazyimg" />
            <img data-load-src="../images/2.jpg" src="" class="lazyimg" />
            <img data-load-src="../images/3.jpg" src="" class="lazyimg" />
            <img data-load-src="../images/4.jpg" src="" class="lazyimg" />
            <img data-load-src="../images/5.jpg" src="" class="lazyimg" />
            <img data-load-src="../images/6.jpg" src="" class="lazyimg" />
            <img data-load-src="../images/5.jpg" src="" class="lazyimg" />
            <img data-load-src="../images/4.jpg" src="" class="lazyimg" />
            <img data-load-src="../images/3.jpg" src="" class="lazyimg" />
            <img data-load-src="../images/2.jpg" src="" class="lazyimg" />
            <img data-load-src="../images/1.jpg" src="" class="lazyimg" />
        </article>
    
    <script src="../scripts/lib/seedsui/seedsui.min.js"></script>
    <!--Exmobi能力-->
    <!--<script src="../scripts/lib/exmobi/exmobi.js"></script>-->
    <script>
        var view={
            /*=========================
              Model
              ===========================*/
            initialize:function(){
                /*DOM*/
                this.btnRefresh=document.getElementById("ID-BtnRefresh");
                /*Plugin*/
                this.iLazy;
                /*Data*/

                /*Render*/
                this.render();
                
                /*Events*/
                this._attach();
            },
            render:function(){
                this._initPlugin();
            },
            /*=========================
              Method
              ===========================*/
            _update:function(){
            },
            /*=========================
              Plugin
              ===========================*/
            _initImgLazy:function(){
                this.iLazy=new Imglazy();
            },
            _initPlugin:function(){
                this._initImgLazy();
            },
            /*=========================
              Events
              ===========================*/
            _attach:function(e){
                var self=this;
                this.btnRefresh.addEventListener("click",function(e){
                    self._onClickBtnRefresh(e);
                },false);
            },
            /*=========================
              Event Handler
              ===========================*/
            _onClickBtnRefresh:function(e){
                var imgStr='<img data-load-src="../images/6.jpg" src="" class="lazyimg" />';
                var img = document.createElement("img");
                img.setAttribute("data-load-src","../images/6.jpg");
                img.className="lazyimg";
                var article=document.querySelector("article");
                article.insertBefore(img,article.querySelector("img"));
                this.iLazy.update();
            }
        }

        window.addEventListener("load",function(){
            view.initialize();
        }, false);

        //定义exmobi返回
        function back(){history.go(-1);}
    </script>
</body>
</html>
